package game;

import boundaryToMatador.GUI;

import java.awt.Color;
import java.awt.color.*;

public class GUIin {

	
	public GUIin()
	{
		
	}
	
	public int getNumberOfPlayers()
	{
		return GUI.getUserInteger("How many players?", 2, 6);
	}
	
	public Player[] addPlayers(Player[] p)
	{
		Color[] c = {Color.LIGHT_GRAY, Color.ORANGE, Color.BLACK, Color.PINK, Color.YELLOW, Color.MAGENTA};
		for (int i=0; i<p.length; i++)
		{
			p[i]= new Player();
			p[i].setName(GUI.getUserString("Player "+(i+1)+"'s name:"));
			while (i>0) {
				boolean out=true;
				for (int k=0; k<i; k++)
				{
					if (p[i].compareName(p[k].getName())) {
						p[i].setName(GUI.getUserString("Name is taken. Try another:"));
					}
				}
				for (int k=0; k<i; k++)
				{
					if (p[i].compareName(p[k].getName())) {
						out=false;
					}
				}
				if (out) break;
			}
			GUI.addPlayer(p[i].getName(), p[i].getAccount(), c[i]);
			GUI.setCar(1, p[i].getName());
		}
		
		return p;
	}
	
	public boolean yesOrNo() {
			
		if(GUI.getUserButtonPressed("Do you want to buy this property", "Yes", "No") == "Yes") {
			GUI.showMessage("You are now the owner");	
			return true;
		}
		else {
			return false;	
		}
	}
	
	public boolean landOnTax(int account) {
	
		GUI.showMessage("You landed on Caravan.");
		if(GUI.getUserButtonPressed("Do you want to pay 4000 or 10% of your assets","4000",Integer.toString(account/10))=="4000") {
			return true;
		}
		else {
			return false;
		}
	}
	
	public boolean playAgain()
	{
		if(GUI.getUserButtonPressed("Do you want to play again?", "Yes", "No")=="Yes")
		return true;
		else return false;
	}
}
